<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

$user_id = get_input('user_id');

$from = get_input('from');
$to = get_input('to');
$count = get_input('count');

$noun = get_input('noun');
$adjective = get_input('adjective');

$games = dt_list_published_game_full($user_id, $from, $to, $count, $noun, $adjective);
//var_dump($games);
if ($games) {
    for($i = 0; $i < count($games); $i++) {
        //var_dump($games[$i]);
        //echo $games[$i]->noun_id;
        //echo $games[$i]->adjective_id;

        $noun_user = dt_get_user_by_user_id($games[$i]->noun_id);
        $adjective_user = dt_get_user_by_user_id($games[$i]->adjective_id);
        //var_dump($noun_user);
        //var_dump($adjective_user);
        if($noun_user) {
            $games[$i]->noun_fbid = $noun_user->facebook_id;
            $games[$i]->noun_name = $noun_user->fullname;
        }
        if($adjective_user) {
            $games[$i]->adjective_fbid = $adjective_user->facebook_id;
            $games[$i]->adjective_name = $adjective_user->fullname;
        }
    }
} else {
    $games = array();
}

echo json_encode(export_result(200, $games));

?>
